package com.example.bigdata.scala.扩展类

/**
  *  Location 类继承 Point的move 方法并重写该方法。
  * 注意 - 在Point类中的move()方法和Location类中的move()方法不会覆盖move的相应定义，因为它们是不同的定义(例如，前者采用两个参数，后者采用三个参数)。
  */

object Testdemo {
  def main(args: Array[String]): Unit = {
    /*val loc = new Location(10,20,15)
    loc.move(10,10,5)*/
    val v1 = new Vehicle(1,1998)
    val c1 = new Car(2,2000,4)

    println(v1.toString)
    println(c1.toString)

    def hi1(a:Int)=(x:Double) => a*x

    println(hi1(10))
    println(Student.uniqueStudentNo())
    println(Student.uniqueStudentNo())
    println(Student.uniqueStudentNo())
  }
}

// 单例模式对象


object Student{
  private var studentNo:Int=0
  def uniqueStudentNo() = {
    studentNo += 1
    studentNo
  }
}

class Vehicle(val id : Int,val year : Int){
  override def toString: String = "ID: " + id +"\tYear :" + year
}

class Car(override val id : Int,override val year : Int, val fuelLevel:Int)extends Vehicle(id, year){
  override def toString: String = super.toString + "\tfuel Level : " + fuelLevel
}


class Point (val xc:Int , val xy:Int) {
  var x = xc
  var y = xy
  def move (dx : Int ,dy : Int ): Unit ={
    x += dx
    y += dy
    println("Point x location : " + x )
    println("Point y location : " + y )
  }
}
class xxx (val a:Int ,val b:Int ,val c:Int) extends Point(a,b){}

class Location(override val xc:Int, val yc:Int, val zc : Int) extends Point(xc,yc){

  var z = zc

  def move (dx:Int,dy:Int,dz:Int): Unit ={
    x += dx
    y += dy
    z += dz
    println("Point x location : " + x )
    println("Point y location : " + y )
    println("Point z location : " + z )

  }


}